Become a Bayesian in
10 minutes

Follow along

m-clark.github.io/workshops/bayesian

“We may regard the present state of the universe as the effect of its past and the cause of its future. An intellect which at a certain moment would know all forces that set nature in motion, and all positions of all items of which nature is composed, if this intellect were also vast enough to submit these data to analysis, it would embrace in a single formula the movements of the greatest bodies of the universe and those of the tiniest atom; for such an intellect nothing would be uncertain and the future just like the past would be present before its eyes…”

~ Laplace, 1814

\[ p(\mathrm{hypothesis}|\mathrm{data}) = \frac{p(\mathrm{data}|\mathrm{hypothesis})p(\mathrm{hypothesis})}{p(\mathrm{data})} \]

\[ \mathrm{posterior} \propto \mathrm{data} * \mathrm{prior}\]

Distributions

The goal is a distribution (stable) rather than a single parameter estimate

Posterior

Posterior distribution

A weighted combination of

Prior

Represents our intution regarding the intial state of affairs

Based on

Prior belief

Prior research

Known approaches that work well in the modeling context

The prior is subjective?!?

Subjective != Arbitrary

For example…

Subjective

Choosing a normal distribution for the likelihood

Subjective

Setting a prior variance to some value

Arbitrary

Setting your null hypothesis parameter value to 0

Arbitrary

Choosing .05 as a cutoff for ‘significance’

Perks: Probabilities

Which interpretation do you prefer?

If I asssume a value of zero for the parameter, what is the probability of my observed parameter or more extreme?

Or

What’s the probability my result is greater than zero?

Perks: Intervals

Which interpretation do you prefer?

If I repeat this study precisely an infinite number of times, and I calculate a P% interval each time, then P% of those intervals will contain the true parameter. Here is one of those intervals.

Or

The probability the parameter falls in this interval is P.

Perks

Intuitive results

Auto-regularization

  • Guards against overfitting

Intervals for anything you can calculate

Which of the following is R code for the Bayesian model?

(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)

Which of the following is R code for the Bayesian model?

lm(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)

Which of the following is R code for the Bayesian model?

lm(mpg ~ wt, data=mtcars)
stan_lm(mpg ~ wt, data=mtcars)   # rstanarm
(mpg ~ wt, data=mtcars)

Which of the following is R code for the Bayesian model?

lm(mpg ~ wt, data=mtcars)
stan_lm(mpg ~ wt, data=mtcars)   # rstanarm
brm(mpg ~ wt, data=mtcars)       # brms

Logistic Regression

glm(treat ~ educ + black + hisp + married, data=lalonde, family='binomial')
stan_glm(treat ~ educ + black + hisp + married, data=lalonde, family='binomial')   # rstanarm
brm(treat ~ educ + black + hisp + married, data=lalonde, family='binomial')        # brms

Ordinal Regression

clm(rating ~ temp*contact, data = wine)                       # ordinal
stan_polr(rating ~ temp*contact, data = wine)                 # rstanarm
brm(rating ~ temp*contact, data = wine, family='ordinal')     # brms

Mixed Model

lmer(Reaction ~ Days + (1 + Days|Subject))        # lme4
stan_lmer(Reaction ~ Days + (1 + Days|Subject))   # rstanarm
brm(Reaction ~ Days + (1 + Days|Subject))         # brms

The Point
















{data}

Rstan and associated packages make it easy to be a Bayesian

Things you’ll need to learn

Settings

Debugging

Diagnostics

Model comparison

Issues

Big data

Very complex models

Indoctrination commencing…

Hold please…

Bayesian Bliss

Join Now!

Can you do any less?!

Go and do likewise!